<?php
/**
 * Created by PhpStorm.
 * User: acker
 * Date: 21-06-08
 * Time: 下午6:25
 */

namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Encore\Admin\Traits\DefaultDatetimeFormat;



class MessageNotificationModel extends Model
{
    use DefaultDatetimeFormat;

    use SoftDeletes;

    /**
     *
     *计量单位
     * @var string
     */
    protected $table = 'yth_message_notification';

    /**
     * 主键
     *
     * @var string
     */
    protected $primaryKey = 'id';


    /**
     * 该模型是否被自动维护时间戳
     *
     * @var bool
     */
    public $timestamps = true;


    /**
     * 添加消息
     */
    protected function addMessage($admin_id,$role_id,$data_id,$data_type,$route_type,$is_handled=0){

        if($route_type == 1){
            //通知库管发货
            $data['name'] = '客户订单发货提醒';
            $data['detail'] ="有一个新的客户订单待您发货！";
        }elseif($route_type == 2){
            //通知采购采购
            $data['name'] = '客户订单采购提醒';
            $data['detail'] ="您有一个新的客户订单待您采购！";
        }elseif($route_type == 3){
            //通知财务确认
            $data['name'] = '采购订单审核提醒';
            $data['detail'] ="您有一个新的采购订单待您审核！";
        }elseif($route_type == 4){
            //通知采购审核不通过
            $data['name'] = '采购订单审核提醒';
            $data['detail'] ="您有一个采购订单审核被驳回！";
        }elseif($route_type == 5){
            //通知采购审核通过
            $data['name'] = '采购订单审核提醒';
            $data['detail'] ="您有一个采购订单审核通过啦！";
        }elseif($route_type == 6){
            //通知产品订单已发货
            $data['name'] = '订单发货提醒';
            $data['detail'] ="有一个新的客户订单已发货！";
        }elseif($route_type == 7){
            //通知仓库入库
            $data['name'] = '采购订单入库提醒';
            $data['detail'] ="有一个采购订单待您入库！";
        }elseif($route_type == 8){
            //通知发货
            $data['name'] = '客户订单发货提醒';
            $data['detail'] ="有一个新的客户订单待您发货！";
        }elseif($route_type == 9){
            //今日采购通知财务审核
            $data['name'] = '采购订单审核提醒';
            $data['detail'] ="有一个今日采购订单待您审核！";
        }elseif($route_type == 10){
            //今日采购订单审核驳回
            $data['name'] = '今日采购订单审核提醒';
            $data['detail'] ="您有一个采购订单审核被驳回！";
        }elseif($route_type == 11){
            //今日采购订单审核通过
            $data['name'] = '今日采购订单入库提醒';
            $data['detail'] ="有一个新的今日采购订单待您入库";
        }elseif($route_type == 12){
            //客户报损通知财务
            $data['name'] = '客户报损审核提醒';
            $data['detail'] ="有一个客户报损单待您审核！";
        }elseif($route_type == 13){
            //今日采购订单审核驳回
            $data['name'] = '客户报损审核提醒';
            $data['detail'] ="您有一个采购订单审核被驳回！";
        }elseif($route_type == 14){
            //今日采购订单审核驳回
            $data['name'] = '客户报损审核提醒';
            $data['detail'] ="您有一个采购订单审核通过啦！";
            $is_handled = 1;
        }elseif($route_type == 15){
            //订单补发审核通知
            $data['name'] = '订单补发审核提醒';
            $data['detail'] ="有一个订单补发待您审核！";
        }elseif($route_type == 16){
            //订单补发审核驳回
            $data['name'] = '订单补发审核提醒';
            $data['detail'] ="您有一个采购订单审核被驳回！";
        }elseif($route_type == 17){
            //订单补发审核通过！
            $data['name'] = '订单补发审核提醒';
            $data['detail'] ="您有一个采购订单审核通过啦！";
        }elseif($route_type == 18){
            //订单补发发货停下
            $data['name'] = '订单补发发货提醒';
            $data['detail'] ="您有一个订单补发待您发货！";
        }elseif($route_type == 19){
            //订单补发发货停下
            $data['name'] = '订单补发采购提醒';
            $data['detail'] ="您有一个订单补发待您采购！";
        }elseif($route_type == 20){
            //订单补发发货停下
            $data['name'] = '采购订单审核提醒';
            $data['detail'] ="有一个订单补发采购订单待您审核！";
        }elseif($route_type == 21){
            //订单补发发货停下
            $data['name'] = '采购订单审核提醒';
            $data['detail'] ="您有一个订单补发采购订单审核被驳回！";
        }elseif($route_type == 22){
            //订单补发发货停下
            $data['name'] = '订单补发发货提醒';
            $data['detail'] ="您有一个订单补发待您发货！";
        }elseif($route_type == 23){
            //订单补发发货停下
            $data['name'] = '订单补发入库提醒';
            $data['detail'] ="您有一个订单补发待您入库！";
        }elseif($route_type == 24){
            //客户退货审核
            $data['name'] = '客户退货审核提醒';
            $data['detail'] ="您有一个客户退货单待您审核！";
        }elseif($route_type == 25){
            //客户退货审核驳回
            $data['name'] = '客户退货审核提醒';
            $data['detail'] ="您有一个客户退货单审核被驳回！";
        }elseif($route_type == 26){
            //客户退货审核通过
            $data['name'] = '客户退货审核提醒';
            $data['detail'] ="您有一个客户退货单审核通过啦！";
        }elseif($route_type == 27){
            //库管报损审核
            $data['name'] = '库管报损审核提醒';
            $data['detail'] ="您有一个库管报损单待您审核！";
        }elseif($route_type == 28) {
            //库管报损审核审核驳回
            $data['name'] = '产品报损审核提醒';
            $data['detail'] ="您有一个产品报损单审核被驳回！";
        }elseif($route_type == 29) {
            //库管报损审核审核通过
            $data['name'] = '产品报损审核提醒';
            $data['detail'] = "您有一个产品报损单审核通过啦！";
        }elseif($route_type == 30){
            //库存修正审核
            $data['name'] = '库存修正审核提醒';
            $data['detail'] ="您有一个库存盘点单待您审核！";
        }elseif($route_type == 31) {
            //库存修正审核审核驳回
            $data['name'] = '库存修正审核提醒';
            $data['detail'] ="您有一个库存盘点单审核被驳回！";
        }elseif($route_type == 32) {
            //库存修正核审核通过
            $data['name'] = '库存修正审核提醒';
            $data['detail'] = "您有一个库存修正单审核通过啦！";
        }

            $data['admin_id'] = $admin_id;
        $data['notifier_id'] = $role_id;
        $data['route_type'] = $route_type;
        $data['route_url'] = $route_type;
        $data['data_id'] = $data_id;
        $data['data_type'] = $data_type;
        $data['is_handled'] = $is_handled;
        $data['created_at'] = date('Y-m-d H:i:s',time());
        MessageNotificationModel::insert($data);

        return true;
    }


}
